HTML Applications

The power to build HTML Applications (HTAs) brings Microsoft® Internet Explorer 5 to the fore as a viable Microsoft Windows® development platform. HTAs are full-fledged applications. These applications are trusted and display only the menus, icons, toolbars, and title information that the Web developer creates. In short, HTAs pack all the power of Internet Explorer—its object model, performance, rendering power, protocol support, and channel-download technology—without enforcing the strict security model and user interface of the browser.

Why Use HTAs

Historically, programming languages like C++ and Microsoft Visual Basic® have provided the object models and access to system resources that developers demand. With HTA it is now time to add Dynamic HTML (DHTML) with script to that list. HTAs not only support everything a Web page does—namely HTML, Cascading Style Sheets (CSS), scripting languages, and behaviors—but also HTA-specific functionality. This added functionality provides control over user interface design and access to the client system. Moreover, run as trusted applications, HTAs are not subject to the same security constraints as Web pages. As with any executable file, the user is asked once, before the HTA is downloaded, whether to save or run the application; if saved to the client machine, it simply runs on demand thereafter. The end result is that HTAs runs like any executable (.exe) written in C++ or Visual Basic.

HTAs are suited to many uses, whether you are prototyping, making wizards, or building full-scale applications. Whatever DHTML and script deliver now—forms, multimedia, Web applications, HTML editors, and browsers—so can HTAs...and then some. Best of all, HTAs make some tasks easier. The simplicity of generating prototypes using HTAs makes it possible for program managers and designers to script dialog boxes and alerts while the C++ or Visual Basic developers program the underlying functionality.

Creating simple HTA

Choose "File\New\Syntax editor" in application menu. Write one line:

Hello, world!

and save file into harddrive with .hta extension (for example, hello.hta). Start this file from Windows Explorer.

For examining HTA properties look at "HTA Properties" example (located in Examples folder in directory where www-Sharp is installed).

Compiling HTML application

www-Sharp lets you compile HTML application into the single file. Unlike www-Sharp.Runtime this solution does not allow server-side scripts. Startup page for compiled HTA is index.hta file in application root directory - this file must present in project.

In application menu choose "File\Compile HTA ...". In file field enter file name into which you want to compile HTA (file should have ".wsits" extension). In directory field enter root directory of your HTA. Check files that you want to compile and press "Compile " button.

Deploying compiled HTML application

Compiled HTA (as well as normal HTA) requires Internet Explorer 5 installed on client computer. You need to deploy compiled file (with ".wsits" extension) and register extension handler (all files needed to handle wsits files are installed yet with IE5+). To register handler for .wsits files you should add some values into registry.

Register for all users on computer (requires administrator privileges on Windows NT 4.0, 2000, XP, 2003):

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.wsits]
@="WSITS file"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WSITS file]
@="Compiled HTML application"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WSITS file\DefaultIcon]
@="itss.dll,0"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WSITS file\shell\open\command]
@="mshta.exe ms-its:%1::/index.hta"
	

Register for current user (not supported on Windows 98, Me, NT 4.0):

REGEDIT4

[HKEY_CURRENT_USER\SOFTWARE\Classes\.wsits]
@="WSITS file"

[HKEY_CURRENT_USER\SOFTWARE\Classes\WSITS file]
@="Compiled HTML application"

[HKEY_CURRENT_USER\SOFTWARE\Classes\WSITS file\DefaultIcon]
@="itss.dll,0"

[HKEY_CURRENT_USER\SOFTWARE\Classes\WSITS file\shell\open\command]
@="mshta.exe ms-its:%1::/index.hta"
	

Copy this code into file with .reg extension and run it on user computer. You may also add these registry settings with your installation program - look its documentation for information on how to do this.

ATTN: you should not customize handler settings for wsits files - user computer may have other wsits files that will not work after such customization. If you need this, register your own extension.

Additional note:

Compiling HTML application is archiving it into format similar to one used by compiled HTML help (.chm) files. This means that those files could be decompiled quite easy.